home *** CD-ROM | disk | FTP | other *** search
- Path: oasis.novia.net!not-for-mail
- From: tsyslo@oasis.novia.net (Tony Syslo)
- Newsgroups: comp.sys.amiga.programmer
- Subject: C compiler problem
- Date: 30 Jan 1996 03:29:37 GMT
- Organization: Novia Internetworking <> 28.8kbps dialup; 402/390-2NET
- Message-ID: <4ek3b2$a5k@nntp.novia.net>
- NNTP-Posting-Host: oasis.novia.net
- X-Newsreader: TIN [UNIX 1.3 BETA-950824-color PL0]
-
- I have a friend who is converting a CNET BBS game from ARREX to C.
- Here is his request:
-
- Can anyone tell me why this program is not compiling?
- I am using SAS/C 6.50, and am getting a BPTR error on line 35 with the
- "struct FileHandle *".
-
- PROGRAM START:
-
- /* File Open */
-
- #include <clib/dos_protos.h>
- #include <dos/dos.h>
- #include <stdio.h>
- #include <exec/types.h>
-
- int main();
-
- char name[80];
- int age;
-
- int main()
-
- {
- struct FileHandle *file_handle;
- long bytes_written;
- long bytes_read;
-
- printf("Enter your name: ");
- scanf("%s",name);
- printf("\nEnter your age: ");
- scanf("%d",&age);
-
-
- file_handle=(struct FileHandle *)
- Open("RAM:You.dat",MODE_NEWFILE);
- /* Have we opened the file successfully? */
- if(file_handle==NULL)
- {
- printf("Could not open the file!\n");
- Exit(0);
- }
- /* We have now opened a file, and are ready to start writing: */
- bytes_written=Write(file_handle,name,sizeof(name));
- bytes_written=bytes_written+Write(file_handle,age,sizeof(age));
- if(bytes_written!=sizeof(name)+sizeof(age))
- {
- printf("Could not save the list!\n");
- Close(file_handle);
- Exit(0);
- }
- else
- printf("Saved successfully!\n");
- printf("Memory cleared!\n");
- name="";
- age=0;
- printf("Loading!\n");
- Seek(file_handle,0,OFFSET_BEGINNING);
- bytes_read=Read(file_handle,name,sizeof(name));
- bytes_read=bytes_read+Read(file_handle,age,sizeof(age));
- if(bytes_read!=sizeof(name)+sizeof(age))
- {
- printf("Could not read the list!\n");
- Close(file_handle);
- Exit(0);
- }
- /* Print out the data: */
- printf("Hello, %s!\",name);
- printf("You are %d years old!\n",age);
- /* Close the file: */
- Close(file_handle);
- }
-
- PROGRAM END:
-
- Also, are there any good random number generators I could use? I am in need
- of a script, or something, that is fast, for a game I am writing, or
- converting, rather... Anything will work, even if it is a psuedo-random
- generator.
-
- Thanx for any and all help!
-
-